package xyz.yuanjilu.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import xyz.yuanjilu.entity.JobEntity;
import xyz.yuanjilu.service.BatchService;
import xyz.yuanjilu.utils.PageUtils;
import xyz.yuanjilu.utils.Query;
import xyz.yuanjilu.utils.R;

@RestController
@RequestMapping("batch")
public class BatchController {
	
	@Autowired
	private BatchService batchService;
	
	  /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("webantmanager:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<JobEntity> jobs = batchService.queryJobs(query);
        int total = batchService.queryJobsTotal(query);
        
        PageUtils pageUtil = new PageUtils(jobs, total, query.getLimit(), query.getPage());
        
        return R.ok().put("page", pageUtil);
    }

}
